home *** CD-ROM | disk | FTP | other *** search
/ Night Owl 6 / Night Owl's Shareware - PDSI-006 - Night Owl Corp (1990).iso / 031a / adman10c.zip / ADIMPORT.WBT < prev    next >
Text File  |  1991-07-31  |  5KB  |  108 lines

  1. :whatfile
  2.  
  3. infile="*.in"                                            ;Create template for a dialog box to prompt user
  4. hFP=FileOpen("adimport.dlg","WRITE")
  5. FileWrite(hFP,"[infile$                                          ]")
  6. FileWrite(hFP,"[infile\          ]")
  7. FileWrite(hFP,"[infile\          ]")
  8. FileWrite(hFP,"[infile\          ]      [i^1Tab delimited file   ]")
  9. FileWrite(hFP,"[infile\          ]      [i^2Comma delimited file ]")
  10. FileWrite(hFP,"[infile\          ]")
  11. FileWrite(hFP,"[infile\          ]")
  12. FileWrite(hFP,"[infile\          ]")
  13. FileClose(hFP)
  14.  
  15.  
  16. DialogBox("AddrMan Converter","adimport.dlg")            ;Pop up ye olde dialog box
  17. CRLF=strcat(num2char(13),num2char(10))                   ;define a CRLF
  18. DELIMIT=Num2Char(9)                                      ;setup delimiter
  19. DELIMITNAME="TABs"                                       ;and a name for the same
  20. if i==2 then DELIMIT=","                                 ;nope, delimites are really commas
  21. if i==2 then DELIMITNAME="COMMAs"                        ; and they are called commas
  22.  
  23.  
  24. count=0                                                  ;initialize record count to zero
  25.  
  26.  
  27. infile = StrUpper(infile)                                ;Make file name all uppercase
  28. If FileExist(infile) == @FALSE Then Goto nofile          ;Ooops can't find file
  29.  
  30.  
  31. if WinExist("Address") then goto runnin
  32. Message("AddrMan Converter","Address Manager not running.  Get it going.")
  33. Exit
  34. :runnin
  35. WinActivate("Address")                                   ;Activate Addrman
  36.  
  37.  
  38. f = FileOpen(infile, "READ")                             ;Open file for input
  39.  
  40. :nextline
  41. l = FileRead(f)                                          ;Read a line
  42. If (l == "*EOF*") Then Goto done                         ;All done???
  43.  
  44. if count>0 then goto contin
  45.                                                          
  46. dummy=strscan(l,DELIMIT,1,@FWDSCAN)                      ;Check first line.  Can we even find a delimiter?
  47. if dummy!=0 then goto doit                               ;Delimiter found.  All is hunky dorey
  48.                                                          ;No delimiter.  User probably chose wrong file delim type
  49. Message("AddrMan Converter","%DELIMITNAME% not found in file %CRLF%Probably specified incorrectly")
  50. FileClose(f)                                             ;Close file
  51. goto whatfile                                            ; and let user try, try again
  52.  
  53. :doit
  54. Sendkey("!ea!u!l")                                       ;all looks good, get data entry dialog box up
  55.  
  56. :contin
  57.  
  58.  
  59. linepointer=1                                            ;Initialize linepointer var
  60. maxpointer=strlen(l)                                     ;Determine end of line
  61. varssent=0                                               ;No vars sent to dialog box for this line (yet)
  62.  
  63.  
  64. :nextvar
  65. thischar=strsub(l,linepointer,1)                         ;Get next character
  66. if thischar=='"' then goto scan4quote                    ;Is it a "  if so, goto scan4quote
  67. nextpointer=strscan(l,DELIMIT,linepointer,@FWDSCAN)      ;go find the next delimiter
  68. if nextpointer==0 then goto doneline                     ;Next delimiter no exist, must be doned
  69. thisvar=strsub(l,linepointer,nextpointer-linepointer)    ;pick out the current variable
  70. linepointer=nextpointer+1                                ;update current line pointer var
  71. goto sendit
  72.  
  73. :scan4quote
  74. nextpointer=strscan(l,'"',linepointer+1,@FWDSCAN)        ;Find next "
  75. if nextpointer==0 then goto doneline                     ;NO "  ??????, oh well we must be done with this line
  76. thisvar=strsub(l,linepointer+1,nextpointer-linepointer-1) ;pick out the current variable
  77. linepointer=nextpointer+2                                ;Update the current line pointer
  78.  
  79. :sendit
  80. if strlen(thisvar)==0 then goto nextone
  81. ;send string to the sendkey cleaners.....cleanup special characters..
  82. thisvar=strreplace(thisvar,'{','{{}')
  83. thisvar=strreplace(thisvar,'~','{~}')
  84. thisvar=strreplace(thisvar,'!','{!}')
  85. thisvar=strreplace(thisvar,'^','{^}')
  86. thisvar=strreplace(thisvar,'+','{+}')
  87.  
  88. SendKey(thisvar)                                         ;Pop variable into the clipboard
  89. :nextone
  90. SendKey("{TAB}")                                ;Splat clipboard data into field, and move to next field
  91. varssent=varssent+1                                      ;Increment count of vars splatted
  92. if varssent>=13 then goto doneline                       ;Have we filled the dialog box...If so ignore rest
  93. if linepointer>maxpointer then goto doneline             ; if no data left one line....must be done....
  94. goto nextvar                                             ;process next field
  95.  
  96.  
  97. :doneline
  98. count=count+1                                            ;Increment record count
  99. SendKey("!a")                                            ;Use SendKey push the "Another" button
  100. Goto nextline                                            ;And do the next record
  101.  
  102. :done
  103. FileClose(f)                                            ;All doned, close file
  104. Message("Processing complete", "%count% records imported from %infile%")
  105. Exit                                                    ;Bye Bye
  106.  
  107.  
  108.